package tongkeyon.create.factory.factory.simple;

import tongkeyon.create.factory.basic.Person;

import java.util.Scanner;

/**
 * @Author: keyon <tongkeyon@163.com>
 * @Date: 2020/2/17 21:52
 * @Version 1.0
 */
public class Family {
    private Person person;
    private Integer index;

    public void live(){
        System.out.println("请输入序号：\n");
        Scanner scanner = new Scanner(System.in);
        if (scanner.hasNextLine()){
            index=scanner.nextInt();

            Person person = PersonSimpleFactory.getPersonInstance(index);
            person.eat();
            person.sleep();
        }

    }
}
/*
当Person接口衍生出更多的对象时，需要不断修改Live的逻辑，引入更多的if...else判断逻辑
没增加一个对象就要修改一次代码违背了开闭原则
 */
